home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Precision Software Appli…tions Silver Collection 4
/
Precision Software Applications Silver Collection Volume 4 (1993).iso
/
stats
/
chadyn.exe
/
YCOMN.C
< prev
next >
Wrap
C/C++ Source or Header
|
1988-11-28
|
3KB
|
122 lines
/****************************** YCOMN.C ************************************/
/************************* NEWTON COMMANDS AND MENU **************************/
/********************* (C) 1986,7,8 by JAMES A. YORKE ************************/
#include "yinclud.h"
int caseNs(CodeName) /* newton method commands */
char *CodeName;
{
int J,
num,
quasi;
TEST("np") {
NewtonPeriod();
return(1);
}
if((strcmp(CodeName, "n1") >= 0 && strcmp(CodeName, "n9") <= 0)
|| (strcmp(CodeName, "q1") >= 0 && strcmp(CodeName, "q9") <= 0)) {
if(level == 2)
scr_clr();/* in desmets pcio.a */
num = CodeName[1] - '0';
quasi = 0; /* quasi = 1 means use Quasi-Newton */
if(CodeName[0] == 'q')
quasi = 1;
for(J = 0; J < num; J++) {
(void) newton(period, quasi);
if(keycheck() == ESC)/* early exit by hitting ESC */
num = J;
}
erase_line();
PRINT "After %d Newton steps y[] is: \n", num);
erase_line();
print_y();
PRINT " \n\n");
return(1);
}
return(0);
}
NewtonMenu() {
if(level == SETPARAM)
scr_clr(); /* in desmets pcio.a */
scr_rowcol(1, 0);
PRINT
" NEWTON'S METHOD MENU \n\n"
);
PRINT
"The Newton method looks for a periodic orbit starting from current value \n"
);
PRINT
" of storage vector y1[]. The new value is put back in y1[]\n");
PRINT
" Recall y1[] can be set using the cursor(arrow) keys while plotting. \n");
PRINT
"Using the arrow keys -- or m or i then 1 -- makes the cross appear at y1[]"
);
PRINT
"\n NP: changes the Period, currently %d.\n", period);
PRINT
" 'period' = the number of plotted points(iterates_per_plot may not be 1)\n"
);
if((num_lyap == -9999) || (vec_dim != 2))
PRINT
"This program is not set up for Newton's method for this process.\n\n");
else {
PRINT
" N1: to take one Newton step \n");
PRINT
" NX: to take X( = 1,...,9) Newton steps \n\n");
PRINT
"The Newton method calculates the step in phase space that would be needed\n");
PRINT
" to make some quantity zero if the map was linear + constant. Since\n");
PRINT
" the map is nonlinear, this step may make matters worse. None-the-less\n");
PRINT
" improvement can be gotten by taking a sufficiently small step in the\n");
PRINT
" recommended direction. Quasi-Newton takes small steps when necessary.\n");
PRINT "\n");
PRINT
" Q1: to take one Quasi-Newton step.\n");
PRINT
" QX: to take X( = 1,...,9) Quasi-Newton steps.\n\n");
}
}
NewtonPeriod() {
int per;
per = period;
if(SCREEN)
PRINT "\nCurrently period is %d. Input new value\n", period);
if(SCREEN)
PRINT
" 'period' = the number of plotted points(iterates_per_plot may not be 1)\n");
per = (int) Entervalue((double) per, CHECKSET);
if(per > 0) {
period = per;
}
else
PRINT
"Need positive value. Currently period is still %d. \n", period);
}